$(function() {
	init();
	optionSearch();
	optNum();
});

function init() {
	$("#table-fundManage").bootstrapTable({

		url: "fundJS/fundMan.json",
		onClickRow:function(row,$element,field) {

                   layer.open({
  type: 2,
  maxmin: true,
  shadeClose: true, 
  area : ['100%' , '100%'],
  content: 'fund2.html'
  });  
			
		},
		onLoadSuccess: function(data) {

			$("#table-fundManage .detail").hide();
			$("#table-fundManage>tbody>tr>td:first-child").hide();
			$("#table-fundManage thead tr th").css("text-align", "center");
			$("#table-fundManage tbody tr td").css("text-align", "center");
		}
	});

	$(".fixed-table-header table").css("display", "");
	$(".fixed-table-body").css({
		"height": "auto"
	});
	
	
	
	
};
function indexFmt(val,row,index){
    return index+1;
}

function resHandler(response) {
	console.log(response);
	var needData = {
		rows: response.data.list,
		total: response.total
	};
	return needData;
}

function optionSearch() {
	$("#clearOption1").click(function() {

		for(var i = 0; i < tums.length - 2; i++) {
			tums[i].value = "";

		}
	})

	$("#searchOption1").on("click", function() {
		var message = {};
		$(".form-control [data-name]").each(function(i, element) {
			message[$(element).attr('data-name')] = $(element).val();
		});
		$("[data-name]").each(function(i, ipt) {
			console.log(ipt);
		});
		console.log(message);
		$.ajax({
			type: "post",
			url: "data.json",
			data: message,
			success: function(data) {
				console.log(data);
			}
		});

	});
	
};

function optNum() {
	var heNanCity = ['信阳市', '郑州市', '开封市', '洛阳市', '周口市'];
	var shanXiCity = ['沈阳市', '大连市', '锦州市', '鞍山市']

	var sel1 = document.getElementById("sel1");

	var sel2 = document.getElementById("sel2");

	sel1.onchange = function() {

		for(var i = 0; i < sel2.children.length; i++) {
			debugger;

			sel2.removeChild(sel2.children[i]);
			i--;
		}

		if(sel1.value == 1) {
			for(var j = 0; j < heNanCity.length; j++) {

				var optionObj = document.createElement('option');

				optionObj.innerHTML = heNanCity[j];

				sel2.appendChild(optionObj);
			}
		}

		if(sel1.value == 2) {
			for(var k = 0; k < shanXiCity.length; k++) {

				var optionObj = document.createElement('option');
				//			
				optionObj.innerHTML = shanXiCity[k];

				sel2.appendChild(optionObj);
			}
		}
	}

}